package com.hisense.hiioc.hismartplate;

import com.hisense.hiioc.hismartplate.server.CoreServer;
import org.mybatis.spring.annotation.MapperScan;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * @Author: almo
 * @Date: 2018/12/5 下午12:48
 * @Version 1.0
 */
@EnableScheduling
@SpringBootApplication
@MapperScan("com.hisense.hiioc.hismartplate.mapper")
@EnableTransactionManagement
public class HiSmartPlateApplication {
    private static final Logger logger = LoggerFactory.getLogger(HiSmartPlateApplication.class);

    public static void main(String[] args) {

        SpringApplication.run(HiSmartPlateApplication.class, args);

        final CoreServer server = new CoreServer();
        server.init();
        server.start();
        // 注册进程钩子，在JVM进程关闭前释放资源
        Runtime.getRuntime().addShutdownHook(new Thread() {
            @Override
            public void run() {
                server.shutDown();
                logger.warn(">>>>>>>>>> jvm shutdown");
                System.exit(0);
            }
        });
    }

}
